package com.mmall.service.impl;

import com.mmall.common.ServerResponse;
import com.mmall.dao.MenuMapper;
import com.mmall.pojo.Menu;
import com.mmall.pojo.Product;
import com.mmall.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("IMenuService")
public class MenuServiceImpl implements IMenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public ServerResponse createMenu(Menu menu) {
        menuMapper.insert(menu);
        return ServerResponse.createByErrorMessage("新增菜单成功");
    }

    @Override
    public ServerResponse updateMenu(Menu menu) {
        menuMapper.updateByPrimaryKey(menu);
        return ServerResponse.createByErrorMessage("更新菜单成功");
    }

    @Override
    public ServerResponse<Menu> deleteMenu(int id) {
        menuMapper.deleteByPrimaryKey(id);
        return ServerResponse.createByErrorMessage("删除菜单成功");
    }

    @Override
    public ServerResponse<List<Menu>> queryAllMenu() {
        List<Menu> menuList = menuMapper.selectAllMenu();
        return ServerResponse.createBySuccess(menuList);
    }

    @Override
    public ServerResponse<List<Menu>> queryAllByUserId(int id) {
        return null;
    }

    @Override
    public ServerResponse<List<Menu>> queryAllByRoleId() {
        return null;
    }

    @Override
    public ServerResponse<Menu> bindRoleAndMenu() {
        return null;
    }
}
